Measurement and calculation of PLC CPU load for different OB types
| LGF_MeasureCpuLoad (FB) | ||||||||
|---|---|---|---|---|---|---|---|---|
| Bool | enable | valid | Bool | |||||
| Bool | reset | busy | Bool | |||||
| Real | loadCascade | error | Bool | |||||
| LGF_typeMeasureCpuLoad_Configuration | configuration | status | Word | |||||
| averagingActive | Bool | |||||||
| loadCascadeActive | Bool | |||||||
| cycleTimeMin | LTime | |||||||
| cycleTimeActual | LTime | |||||||
| cycleTimeMax | LTime | |||||||
| cycleTimeMaxConfigured | LTime | |||||||
| runtime | LReal | |||||||
| cpuLoad | Real | |||||||
| comLoad | Real | |||||||
| comLoadConfigured | Real | |||||||
| limitWarning | Bool | |||||||
| limitAlarm | Bool | |||||||
| resultsCyclic | Array[0..#LAST_CYCLIC_BLOCK_INDEX] of LGF_typeMeasureCpuLoad_ResultBlock | |||||||
| results | Array[0..#LAST_BLOCK_INDEX] of LGF_typeMeasureCpuLoad_ResultBlock | |||||||
| diagnostics | LGF_typeDiagnostics | |||||||
| Identifier | Data type | Default value | Description |
|---|---|---|---|
| enable | Bool | FALSE | TRUE: Enable functionality of FB |
| reset | Bool | FALSE | Rising edge: Reset all internal values and as well PLC CPU timing statistic |
| loadCascade | Real | 0.0 | Percentage Load Value from another `LGF_MeasureCpuLoad` [%] (Connect `cpuLoad` from predecessor instance call) |
| configuration | LGF_typeMeasureCpuLoad_Configuration | --- | This UDT belongs to the Module `LGF_MeasureCpuLoad` and lists all possible parameter to configure its behavior. |
| Identifier | Data type | Description |
|---|---|---|
| valid | Bool | TRUE: Valid set of output values available at the FB |
| busy | Bool | TRUE: FB is not finished, and new output values can be expected |
| error | Bool | TRUE: An error occurred during the execution of the FB |
| status | Word | 16#0000 - 16#7FFF: Status of the FB, 16#8000 - 16#FFFF: Error identification |
| averagingActive | Bool | TRUE: Averaging of actual values active |
| loadCascadeActive | Bool | TRUE: Load calculation cascade active |
| cycleTimeMin | LTime | Minimum cycle time [ms] |
| cycleTimeActual | LTime | Actual cycle time [ms] |
| cycleTimeMax | LTime | Maximum cycle time [ms] |
| cycleTimeMaxConfigured | LTime | Configured maximum cycle time [ms] (in plc hardware configuration) |
| runtime | LReal | Actual cycle time incl. interrupts [ms] |
| cpuLoad | Real | Actual PLC CPU load [%] |
| comLoad | Real | Actual communication load [%] |
| comLoadConfigured | Real | Configured communication load [%] |
| limitWarning | Bool | Load more than configured threshold value 'configuration.limitWarning' |
| limitAlarm | Bool | Load more than configured threshold value 'configuration.limitAlarm' |
| resultsCyclic | Array[0..#LAST_CYCLIC_BLOCK_INDEX] of LGF_typeMeasureCpuLoad_ResultBlock | Results of Cyclic OB read outs |
| results | Array[0..#LAST_BLOCK_INDEX] of LGF_typeMeasureCpuLoad_ResultBlock | Results of NON-Cyclic OB read outs |
| diagnostics | LGF_typeDiagnostics | Diagnostic structure to store and transfer diagnostic information from blocks through the interface. |
| Code / Value | Identifier / Description |
|---|---|
| 16#7000 | STATUS_NO_CALL No job being currently processed |
| 16#7001 | STATUS_FIRST_CALL First call after incoming new job (rising edge 'enable') |
| 16#7002 | STATUS_SUBSEQUENT_CALL Subsequent call during active processing without further details |
| 16#8600 | ERR_UNDEFINED_STATE Error: Due to an undefined state in state machine |
| 16#8601 | ERROR_RTINFO_CONFIGURED_MAX_CYCLETIME Error: RT INFO read configured MAX cycle time Information |
| 16#8602 | ERROR_RTINFO_CONFIGURED_COM_LOAD Error: RT INFO read configured COM Load Information |
| 16#8610 | ERROR_RTINFO_ACTUAL_CYCLETIME Error: RT INFO read actual cycle time Information |
| 16#8611 | ERROR_RTINFO_ACTUAL_MIN_CYCLETIME Error: RT INFO read MIN cycle time Information |
| 16#8612 | ERROR_RTINFO_ACTUAL_MAX_CYCLETIME Error: RT INFO read MAX cycle time Information |
| 16#8620 | ERROR_RTINFO_ACTUAL_COM_LOAD Error: RT INFO read actual COM Load Information |
| 16#8630 | ERROR_RTINFO_RESET_STATISTICS Error: RT INFO reset statistic information |
| 16#9000 | ERROR_RTINFO_RUNTIME_OB_CYCLIC Error: Read RT INFO cycle time Information OB + index of OB in array |
| 16#9100 | ERROR_RTINFO_RUNTIME_OB Error: Read RT INFO cycle time Information OB + index of OB in array |
This UDT belongs to the Module LGF_MeasureCpuLoad and lists all possible parameter to configure its behavior.
| Identifier | Data type | Default value | Description |
|---|---|---|---|
| cfcRun | Bool | FALSE | CFC Run (OB No is shifted to 10xx) |
| averagingValues | USInt | 0 | Averaging the measured values by building the arithmetic average value |
| comLoadSim | UInt | 0 | Com Load Simulation [%] IF > 0.0 used as value for calculation IF <= 0.0 take real com load value read from PLC |
| limitWarning | Real | 70.0 | Warning threshold value [%] |
| limitAlarm | Real | 100.0 | Alarming threshold value [%] |
| organizationBlocksCyclic | Array[0..10] of LGF_typeMeasureCpuLoad_ConfigurationBlock | --- | Cyclic Blocks to measure |
| organizationBlocks | Array[0..30] of LGF_typeMeasureCpuLoad_ConfigurationBlock | --- | NON-Cyclic Blocks to measure |
Configuration for the block to be measured
| Identifier | Data type | Default value | Description |
|---|---|---|---|
| enableMeasurement | Bool | FALSE | Enable measurement |
| obNumber | Int | 0 | Organization's Block Number of the module to be measured |
| initialLoad | Real | 0.0 | Initial load [%], only used if averaging is turned on |
Results for Block measured
| Identifier | Data type | Default value | Description |
|---|---|---|---|
| obNumber | Int | 0 | Organisation Block Number |
| runtime | LTime | --- | Runtime of Organization block [ms] |
| cycleLoad | Real | 0.0 | Load of block calculated using the cycle time [%] |
| maxCycleLoad | Real | 0.0 | Load of block calculated using the MAX cycle time [%] |
| error | Bool | FALSE | TRUE: An error occurred during reading block statistic |
| status | Word | 16#0000 | 16#0000 - 16#7FFF: Status of the `RT_INFO`, 16#8000 - 16#FFFF: Error identification |
Diagnostic structure to store and transfer diagnostic information from blocks through the interface.
| Identifier | Data type | Default value | Description |
|---|---|---|---|
| status | Word | 16#0000 | Status of the Block or error identification when error occurred |
| subfunctionStatus | Word | 16#0000 | Status or return value of called FB's, FC's and system blocks |
| stateNumber | DInt | 0 | State in the state machine of the block where the error occurred |
This function can be used to read out the various runtimes of organizational blocks (OB) and calculate the PLC CPU load based on the results.
The OBs to be considered are specified and activated in the configuration; please note that cyclical and acyclically OBs must be configured in separate structures.
It is also possible to
| Version & Date | Change description | |
|---|---|---|
| 1.0.0 | SAG BG | |
| 19.05.2024 | First Release | |
| 1.1.0 | SAG BG | |
| 06.05.2024 | Add Output with overall runtime incl. interrupts | |
| 1.1.1 | Siemens System Support | |
| 03.09.2025 | Bugfixed error in loop | |